﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryManagementSystem
{
    public partial class 用户页面 : Form
    {
        //声明自适应类实例
        AutoSizeFormClass asc = new AutoSizeFormClass();

        //子窗体
        借阅记录 boRecordForm = new 借阅记录();
        修改信息 updateForm = new 修改信息();

        //Id属性
        private string id;
        public string Id
        {
            get { return id; }
            set { id = value; }
        }


        public 用户页面()
        {
            InitializeComponent();
            this.Resize += new System.EventHandler(用户页面_Resize);
        }

        #region 控件大小变化
        private void 用户页面_Resize(object sender, EventArgs e)
        {
            asc.controlAutoSize(this);
        }

        private void 用户页面_Load(object sender, EventArgs e)
        {
            asc.controllInitializeSize(this);
            idTxb.Text = Id + "，欢迎登录！";

        }
        #endregion

        #region 显示子窗体
        public void showForm(Form subForm)
        {
            panel1.Controls.Clear();
            subForm.TopLevel = false;//非顶级控件
            subForm.FormBorderStyle = FormBorderStyle.None;//不显示标题栏
            subForm.WindowState = FormWindowState.Normal; //默认窗体大小	
            subForm.Dock = DockStyle.Fill;//填充panel
            this.panel1.Controls.Add(subForm);//添加子窗体
            subForm.Show();
        }

        private void 借阅记录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showForm(boRecordForm);
        }

        private void 修改信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            showForm(updateForm);
        }

        private void 退出登录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认退出吗？", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                this.Close();
            }
        }
        #endregion
    }
}
